package com.daisuxia.web.pojo;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class RepaymentDetail {
//  1、支付宝、2、银行卡主动还款、3、银行卡自动扣款、4、对公银行卡转账、5、线下还款
    public static final int TYPE_ALIPAY = 1;
    public static final int TYPE_BANK_CARD = 2;
    public static final int TYPE_BANK_CARD_AUTO = 3;
    public static final int TYPE_BANK_CARD_TRANSFER = 4;
    public static final int TYPE_OFF_LINE = 5;
    public static final int TYPE_OFF_LINE_DEDUCTION= 6;
    public static final int TYPE_WX_SAO = 7;
    public static final int TYPE_ALIPAY_SAO = 8;

    /** 该笔请求等待中 */
    public static final int STATUS_WAIT = 0;
    /** 该笔请求的非成功状态 */
    public static final int STATUS_OTHER = 1;
    /** 该笔请求的成功状态 */
    public static final int STATUS_SUC = 2;

    public static final Map<Integer, String> REPAY_TYPE = new HashMap<Integer, String>();

    static {
        REPAY_TYPE.put(TYPE_ALIPAY, "支付宝还款");
        REPAY_TYPE.put(TYPE_WX_SAO, "微信扫码还款");
        REPAY_TYPE.put(TYPE_ALIPAY_SAO, "支付宝扫码还款");
        REPAY_TYPE.put(TYPE_BANK_CARD, "银行卡主动还款");
        REPAY_TYPE.put(TYPE_BANK_CARD_AUTO, "银行卡自动扣款");
        REPAY_TYPE.put(TYPE_BANK_CARD_TRANSFER, "对公银行卡转账");
        REPAY_TYPE.put(TYPE_OFF_LINE, "线下还款");
        REPAY_TYPE.put(TYPE_OFF_LINE_DEDUCTION, "线下协商免还款");
    }


    private Integer id;

    private Integer assetOrderId;

    private Integer assetRepaymentId;

    private Integer userId;

    private Integer repaymentType;

    private Long trueRepaymentMoney;

    private String remark;

    private String orderId;

    private Date createdAt;

    private Date updatedAt;

    private Integer cardId;

    private String adminUsername;

    private Integer status;

    private String repaymentImg;

    // 扩展字段
    private String createdAtStr;

    private BigDecimal trueRepaymentMoneyBig;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getAssetOrderId() {
        return assetOrderId;
    }

    public void setAssetOrderId(Integer assetOrderId) {
        this.assetOrderId = assetOrderId;
    }

    public Integer getAssetRepaymentId() {
        return assetRepaymentId;
    }

    public void setAssetRepaymentId(Integer assetRepaymentId) {
        this.assetRepaymentId = assetRepaymentId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getRepaymentType() {
        return repaymentType;
    }

    public void setRepaymentType(Integer repaymentType) {
        this.repaymentType = repaymentType;
    }

    public Long getTrueRepaymentMoney() {
        return trueRepaymentMoney;
    }

    public void setTrueRepaymentMoney(Long trueRepaymentMoney) {
        this.trueRepaymentMoney = trueRepaymentMoney;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId == null ? null : orderId.trim();
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Integer getCardId() {
        return cardId;
    }

    public void setCardId(Integer cardId) {
        this.cardId = cardId;
    }

    public String getAdminUsername() {
        return adminUsername;
    }

    public void setAdminUsername(String adminUsername) {
        this.adminUsername = adminUsername == null ? null : adminUsername.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRepaymentImg() {
        return repaymentImg;
    }

    public void setRepaymentImg(String repaymentImg) {
        this.repaymentImg = repaymentImg == null ? null : repaymentImg.trim();
    }

    public String getCreatedAtStr() {
        return createdAtStr;
    }

    public void setCreatedAtStr(String createdAtStr) {
        if(StringUtils.isNotBlank(createdAtStr)){
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                Date createdAt = dateFormat.parse(createdAtStr);
                setCreatedAt(createdAt);;
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        this.createdAtStr = createdAtStr;
    }

    public BigDecimal getTrueRepaymentMoneyBig() {
        return trueRepaymentMoneyBig;
    }

    public void setTrueRepaymentMoneyBig(BigDecimal trueRepaymentMoneyBig) {
        if(null != trueRepaymentMoneyBig){
            setTrueRepaymentMoney(trueRepaymentMoneyBig.multiply(new BigDecimal(100)).longValue());
        }
        this.trueRepaymentMoneyBig = trueRepaymentMoneyBig;
    }
}